
#include "GameObject.h"

Vector2 GameObject::GetPos()
{
	return m_Pos;
}

size GameObject::GetSize()
{
	return m_Size;
}

GameObject::GameObject(void)   
{
	m_Pos.x = 0;
	m_Pos.y = 0;
	m_Size.width = 0;
	m_Size.height = 0;
	m_dLastSpriteTime = 0;

	
}

GameObject::GameObject(float _x, float _y, int _width, int _height)
{
	m_Pos.x = static_cast<int>(_x);
	m_Pos.y = static_cast<int>(_y);
	m_Size.width = _width;
	m_Size.height = _height;
	m_dLastSpriteTime = 0;
}

GameObject::~GameObject(void)
{
		
}


	//Bitmap
HDC GameObject::GetHDC() const
{
	return m_hCurrentDC;
}

void GameObject::SetHDC(HDC _hdc, HDC _hdc2)
{	
	m_hCurrentDC = _hdc;

	if(_hdc2)
	{
		m_hDCs.push_back(_hdc);
		m_hDCs.push_back(_hdc2);
	}
}

void GameObject::SetHDC(HDC* _hdcArray, int _iSize)
{
	
	m_hCurrentDC = *_hdcArray; //Set first element of array to current hDC
	//Fill in the vector of HDCs
	for(int i = 0; i < _iSize; i++)
	{
		this->m_hDCs.push_back(_hdcArray[i]);
	}
}

void GameObject::SetPos(int _iX, int _iY)
{
	m_Pos.x = _iX;
	m_Pos.y = _iY;
}

void GameObject::Move(Vector2 _Dir)
{
	m_Pos += _Dir;
}

void GameObject::Draw(HDC _hBBDC)
{
	BitBlt(_hBBDC, m_Pos.x, m_Pos.y, m_Size.width, m_Size.height, m_hCurrentDC, 0, 0, SRCAND);
}

bool GameObject::CheckCollision(Vector2 _MouseClickPos)
{
	if(_MouseClickPos.x < m_Pos.x) return false;

	if(_MouseClickPos.x > m_Pos.x + m_Size.width) return false;

	if(_MouseClickPos.y < m_Pos.y) return false;

	if(_MouseClickPos.y > m_Pos.y + m_Size.height) return false; //Account for offset on cards behind others

	return true;
}


void GameObject::ToggleCurrentDC()
{
	auto _iter = m_hDCs.begin();
	while(_iter != m_hDCs.end())
	{
		if(*_iter != m_hCurrentDC)
		{
			m_hCurrentDC = *_iter;
			return;
		}
		_iter++;
	}
}